
package org.testfire.realm.control;

/**
 * A class for assisting in the navigation 'issues' created by working with
 * a Faces context -and- a non-faces context. Because it is possible to have
 * two different 'roots', we use constants and getters in order to ensure that
 * changing context roots
 * For instance, renaming FacesContext from MySite name to MyNewFacesSiteName results
 * in the url changing from
 * 'http://localhost/MySiteName/'
 * to
 * 'http://localhost/MyNewFacesSiteName/'
 *
 * The JavaServerFaces pages will see a root which is actually the root plus the context root.
 * Which is to say:
 * In the FacesContext (any file which matches the url pattern in the servlet-mapping tag of
 * web.xml) the root of the page:
 * http://localhost/myContextRoot/abc.jsf
 * will be
 * http://localhost/myContextRoot/
 * whereas if the file were NOT processed by the faces context:
 * http://localhost/myContextRoot/abc.html
 * would have the root of
 * http://localhost/
 *
 * This can cause painful problems which are remedied by using a JSP call to get the
 * value for certain links that we will want; such as javascript and css files, and
 * to navigate to the ssl secured port (https:// -- usually port 81 or 8181).
 *
 * So once we map them here, we can change our web.xml context-root tag, and
 * only have to merge one value -- the contexRoot value of this file.
 * @author Geoff M. Granum
 * @version 1.0
 */

public class NavBean {
    String contextRoot = "/testFireServer";
    String host = System.getProperty( "server.host");
	String port = ":" + System.getProperty( "server.http.port");
	String securePort = ":" + System.getProperty( "server.https.port");
    String href_secure_root = String.format("https://%1$s%2$s%3$s", host, securePort, contextRoot );
    String href_root = String.format("http://%1$s%2$s%3$s", host, port, contextRoot );
    // Root
    String href_dir_root = href_root;
    String href_home = href_dir_root + "/home.jsf";
    String href_contact = href_dir_root + "/contact.jsf";
    String href_about = href_dir_root + "/about.jsf";
    String href_faq = href_dir_root + "/faq.jsf";

    // User
    String href_dir_users = href_dir_root + "/user";
    String href_logout = href_dir_users + "/logout.jsf";
    String href_account = href_dir_users + "/account.jsf";


    // Login
    String href_dir_login = href_dir_root + "/login";
    String href_login = href_dir_login + "/login.jsf";
    String href_register = href_secure_root + "/login/register.jsf";
    String href_register_welcome = href_root + "/login/register_welcome.jsf";
    String href_register_confirm = href_root + "/login/confirm.jsf";

    // Land
    String href_dir_land = href_dir_root + "/land";
    String href_edit_land = href_dir_land + "/edit_property.jsf";
    String href_new_land = href_dir_land + "/new_property.jsf";
    String href_search = href_dir_land + "/propertysearch.jsf";

    // CSS
    String href_dir_css = href_dir_root + "/css";
    String href_css_basic = href_dir_css + "/basic.css";


    // JS
    String href_dir_js = href_dir_root + "/javascript";
    String href_js_displayTools = href_dir_js + "/displayTools.js";
    String href_js_md5 = href_dir_js + "/md5.js";
    String href_js_tools = href_dir_js + "/ajaxTools.js";


    public NavBean() {
    }


    public String getContextRoot() {
        return contextRoot;
    }

    public String getHref_dir_js() {
        return href_dir_js;
    }

    public String getHref_js_displayTools() {
        return href_js_displayTools;
    }

    public String getHref_js_md5() {
        return href_js_md5;
    }

    public String getHref_js_tools() {
        return href_js_tools;
    }

    public String getHref_about() {
        return href_about;
    }

    public String getHref_css_basic() {
        return href_css_basic;
    }

    public String getHref_dir_css() {
        return href_dir_css;
    }

    public String getHref_dir_land() {
        return href_dir_land;
    }

    public String getHref_dir_root() {
        return href_dir_root;
    }

    public String getHref_dir_users() {
        return href_dir_users;
    }

    public String getHref_faq() {
        return href_faq;
    }

    public String getHref_home() {
        return href_home;
    }

    public String getHref_login() {
        return href_login;
    }

    public String getHref_logout() {
        return href_logout;
    }

    public String getHref_search() {
        return href_search;
    }

    public String getHref_contact() {
        return href_contact;
    }

    public String getHref_register() {
        return href_register;
    }

    public String getHref_edit_land() {
        return href_edit_land;
    }

    public String getHref_new_land() {
        return href_new_land;
    }

    public String getHref_dir_login() {
        return href_dir_login;
    }

    public String getHref_account() {
        return href_account;
    }

    public String getHref_register_welcome() {
        return href_register_welcome;
    }

    public String getHref_root() {
        return href_root;
    }

    public String getHref_secure_root() {
        return href_secure_root;
    }

    public String getHref_register_confirm() {
        return href_register_confirm;
    }
}
